package DataFile;

import java.nio.ByteBuffer;

public class Structure_Template {

	protected int baseAdress;	
		
	public static final int ADRESS_WIDTH     = 4;
	public static final int SIZE_FIELD_WIDTH = 4;
	public static final int SHORT_WIDTH      = 2;
	public static final int BYTE_WIDTH       = 1;
	public static final int INTEGER_WIDTH    = 4;
	public static final int LONG_WIDTH       = 8;
	public static final int DOUBLE_WIDTH     = 8;
	public static final int FLOAT_WIDTH      = INTEGER_WIDTH;

	public Structure_Template() {
		// empty
	}

	protected int setBaseAddress(int newBaseAdress) {
		baseAdress=newBaseAdress;
		return(baseAdress+getMemorySize());
	}

	/*
	 * Gets size in memory of this Object 
	 */
	protected int getMemorySize() {
		return(0);
	}

/**************** Tables ***********************************/

/*
 * Gets size in memory of data that is pointed of in this table 
 */
/*
protected int getTableDataMemorySize()
{
return(0);	
}
*/
/*
 * Gets size of this  
 */

	protected String getMemoryMapAsString() {
		String returnString;
		
		returnString=getAdressAsHexString(baseAdress);
		
		return(returnString);
	}

	public int getBaseAddress() {
		return(baseAdress);	
	}
	
	public String getBaseAdressAsHexString() {
		return(getAdressAsHexString(baseAdress));	
	}

	public String getAdressAsHexString(int adress) {
		String returnString;
		String prefixString;
		int counter;
	
		returnString=Integer.toHexString(adress);
		prefixString="0x";
		
		for (counter=returnString.length();counter<8;counter++) {
			prefixString+="0";
		}
	
		return(prefixString+returnString);	
	}

	public void writeData(ByteBuffer fileData) {}

}
